-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Implement GH-18261: Allow cast to be used in constant expressions #18264
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM otherwise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks correct to me now. Thank you!
UPGRADING
Outdated
@@ -130,6 +130,7 @@ PHP 8.5 UPGRADE NOTES | |||
RFC: https://wiki.php.net/rfc/marking_return_value_as_important | |||
. Added asymmetric visibility support for static properties. | |||
RFC: https://wiki.php.net/rfc/static-aviz | |||
. It is now possible to use casts in constant expressions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: "Added support for casts in constant expressions" for consistency?
case IS_OBJECT: | ||
zend_cast_zval_to_object(result, &op1, IS_VAR); | ||
break; | ||
EMPTY_SWITCH_DEFAULT_CASE(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what about the new (void)
cast?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Void casts are not allowed in expression context, only when their return value is not used. This never applies to constant expressions. This is also a different ast type (ZEND_AST_CAST_VOID
), so it doesn't need to be handled here.
No description provided.